#include <windows.h>
#include <iostream>
#include <vector>
#include <string>

#include "common/ICD.hpp"

using namespace std;

typedef void ( *GetICDFun)(ICD& icd);

int main(int argc, char** argv)
{
    std::vector<HMODULE> mods;
    ICD icd;
    for(int i = 0; i< 10;i++)
    {
        icd.iData[i] = i;
    }
    
    for (size_t i = 0; i < 10; i++)
    {
        /* code */
        std::string dllName = "dll" + std::to_string(i) + ".dll";
        if(i == 0) dllName = "dll.dll";
    
        auto h = LoadLibrary(dllName.c_str());
        if(!h)
        {
            cout << "loadLibrary fail!" << endl; 
            continue;
        }
        mods.push_back(h);

        auto GetICDI = (GetICDFun)GetProcAddress(h,"GetICD");
        GetICDI(icd);    
    }

    for(auto& h:mods)
        FreeLibrary(h);

    return 0;
}
